﻿<controls:ChildWindow x:Class="TelecoSystems.Views.Profile.UserProfileView"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:cmd="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
           Width="380" 
           Title="User Profile" xmlns:df="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Vertical">
            <df:DataForm Margin="10" Header="Profile" CurrentItem="{Binding UserDetail, Mode=TwoWay}" AutoCommit="True" AutoEdit="True" EditEnded="DataForm_EditEnded" CommandButtonsVisibility="Commit,Cancel" HorizontalAlignment="Center">
                <df:DataForm.EditTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>                                
                                <ColumnDefinition Width="140"/>
                                <ColumnDefinition Width="160"/>
                            </Grid.ColumnDefinitions>                            
                            <TextBlock Grid.Column="0" Grid.Row="0" Text="Meno" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding FriendlyName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Margin="5" />
                            <TextBlock Grid.Column="0" Grid.Row="1" Text="E-mail" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Email, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Margin="5" />
                            <TextBlock Grid.Column="0" Grid.Row="2" Text="Phone" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Phone, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Margin="5" />
                            <TextBlock Grid.Column="0" Grid.Row="3" Text="Login" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <TextBox Grid.Column="1" Grid.Row="3" IsReadOnly="True" Text="{Binding Name, Mode=OneWay}" Margin="5" />
                            <TextBlock Grid.Column="0" Grid.Row="4" Text="Roly" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <ListBox Grid.Column="1" Grid.Row="4" ItemsSource="{Binding Roles, Mode=OneWay}" Margin="5"/>
                        </Grid>
                    </DataTemplate>
                </df:DataForm.EditTemplate>
            </df:DataForm>

            <Grid Margin="0,0,8,0">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="140"/>
                    <ColumnDefinition Width="160" />
                </Grid.ColumnDefinitions>
                <Image Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" Width="48" Height="48" Source="/TelecoSystems;component/Assets/Images/password.png" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <TextBlock Grid.Column="1" Grid.Row="0" Text="Old password: " HorizontalAlignment="Right" VerticalAlignment="Center" />
                <PasswordBox Grid.Column="2" Grid.Row="0" PasswordChar="*" Password="{Binding PasswordChange.OldPassword, Mode=TwoWay}" Margin="5" />
                <TextBlock Grid.Column="1" Grid.Row="1" Text="New password: " HorizontalAlignment="Right" VerticalAlignment="Center" />
                <PasswordBox Grid.Column="2" Grid.Row="1" PasswordChar="*" Password="{Binding PasswordChange.NewPassword, Mode=TwoWay}" Margin="5" />
                <TextBlock Grid.Column="1" Grid.Row="2" Text="Reply new password: " HorizontalAlignment="Right" VerticalAlignment="Center" />
                <PasswordBox Grid.Column="2" Grid.Row="2" PasswordChar="*" Password="{Binding PasswordChange.NewPasswordReply, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Margin="5" />
            </Grid>

            <Button cmd:Click.Command="{Binding ChangePasswordCommand}" Content="Change password" Height="23" HorizontalAlignment="Right" Margin="5,5,14,5" BorderThickness="1" Width="130" />
        </StackPanel>
        <Button x:Name="CancelButton" Content="Close" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>